#include<bits/stdc++.h>
using namespace std;
long long n,l,r,nn,lj,ans;
long long x,y,z;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin>>n>>l>>r;
	x=l/n;
	y=l%n;
	if(r-l+y>=n-1)
	{
		cout<<n-1;
	}
	else
	{
		cout<<r-l+y;
	}
	return 0;
}
